import request from '@/utils/request'
import base from '../base'

/**
 *  @获取授权页
 *  @returns { Object }  授权信息对象
 */
export function getAuthorization() {
    return request({
        method: 'get',
        url: base.WU + '/passport/grant'
    })
}

/**
 *  @授权
 *  @param { String } code 授权码
 */
export function makeAuthorization(key) {
    return request({
        method: 'post',
        url: base.WU + '/passport/grant',
        params: {
            key
        }
    })
}

/**
 *  @登录
 *  @param { String } userName
 *  @param { String } password
 */
export function login({ password, userName }) {
    return request({
        method: 'post',
        url: base.WU + '/login',
        data: {
            userName,
            password
        }
    })
}

/**
 *  @修改个人信息
 *  @param { String } userName
 *  @param { String } password
 */
export function editUserInfo(data) {
    return request({
        method: 'put',
        url: base.WU + '/login',
        data
    })
}

/**
 *  @修改密码
 *  @param { String } userName
 *  @param { String } password
 */
export function editUserPassword(data) {
    return request({
        method: 'put',
        url: base.WU + '/login/password',
        data
    })
}

/**
 *  @登出
 *  @param { String } userName
 *  @param { String } password
 */
export function loginOut() {
    return request({
        method: 'get',
        url: base.WU + '/login'
    })
}

/**
 *  @权限路由
 *
 */
export function getPermissionRoles() {
    return request({
        method: 'get',
        url: base.WU + '/login/current'
    })
}
